package com.byzk.p2p.admin.web.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.byzk.p2p.admin.base.util.PageInfo;
import com.byzk.p2p.admin.web.dao.BannerDao;
import com.byzk.p2p.admin.web.dto.Banner;
import com.byzk.p2p.admin.web.vo.BannerVo;

@Service
public class BannerService {
	@Autowired
	private BannerDao bannerDao;
	
	public PageInfo<BannerVo> bannerList(BannerVo vo) {
		int count=bannerDao.count(vo);
		List<BannerVo> voList=bannerDao.bannerList( vo);
		PageInfo<BannerVo> page= new PageInfo<BannerVo>(count, vo.getIndex() , vo.getLimit());
		page.setPageList(voList);
		return page;
	}
	
	public Integer saveBanner(Banner banner){
		if (banner.getId() == null) {
			return bannerDao.insert(banner);
		}else{
			return bannerDao.update(banner);
		}
	}
	
	public BannerVo getBannerById(int id){
		return bannerDao.getBannerById(id);
	}
	
	public List<BannerVo> listBanner(Banner banner){
		return bannerDao.listBanner(banner);
	}
	
	/**
	 * 删除banner
	 * @param id
	 * @return
	 */
	public Integer deleteBanner(Integer id){
		return bannerDao.deleteBanner(id);
	}
}
